
package org.finegold.core.context.config;

import org.finegold.core.context.FineHttpHeadersGetter;
import org.finegold.core.context.listener.FineServletRequestListener;
import org.finegold.core.context.props.FineContextProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Servlet 监听器自动配置
 *
 * @author QinXueFeng
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class FineServletListenerConfiguration {

	@Bean
	public ServletListenerRegistrationBean<?> registerCustomListener(FineContextProperties properties,
                                                                     org.finegold.core.context.FineHttpHeadersGetter httpHeadersGetter) {
		return new ServletListenerRegistrationBean<>(new FineServletRequestListener(properties, httpHeadersGetter));
	}

}
